<template>
  <div class="hot-courses">
    <h3 class="title">热门课程 <span class="view-all">查看全部 &gt;</span></h3>
    <div class="course-list">
      <div 
        v-for="(course, index) in hotCourses" 
        :key="course.title" 
        class="course-item"
      >
        <div class="top-badge" v-if="index < 3">
          <span>TOP {{ index + 1 }}</span>
        </div>
        <img src="@/assets/background.jpg" alt="Course Image" class="course-image" />
        <div class="course-info">
          <h4>{{ course.title }}</h4>
          <p class="price">¥{{ course.price }}</p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      hotCourses: [
        { title: '一元二次方程', price: 125 },
        { title: '高考英语全解', price: 228 },
        { title: '语文作文写作技巧', price: 69 },
        { title: '小学英语', price: 26 },
        { title: '奥数的秘密', price: 319 }
      ]
    };
  }
};
</script>
<style scoped>
.hot-courses {
  background-color: #fff;
  border-radius: 8px;
  padding: 20px;
}

.title {
  font-size: 18px;
  margin-bottom: 20px;
}

.view-all {
  font-size: 14px;
  color: #337ab7;
  float: right;
}

.course-list {
  display: flex;
  gap: 20px;
}

.course-item {
  position: relative;
  width: 180px;
  text-align: center;
}

.top-badge {
  position: absolute;
  top: 0;
  left: 0;
  background-color: #d9534f;
  color: #fff;
  padding: 5px 10px;
  border-bottom-right-radius: 5px;
}

.course-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  margin-bottom: 10px;
}

.course-info h4 {
  font-size: 16px;
  margin: 10px 0;
}

.course-info .price {
  color: red;
  font-weight: bold;
}
</style>